package com.hctforgreen.greenservice;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

import com.hctforgreen.greenservice.ui.adapter.NewsListAdapter;
import com.hctforgreen.greenservice.ui.handler.NewsListHandler;
import com.hctforgreen.greenservice.ui.widget.PullToRefreshListView;

/**
 * 新闻列表界面
 * 
 * @author Dhb
 * 
 */
public class NewsActivity extends ParentActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_msg_list);// 共用消息搜索列表的页面
		initSkinLayout();
		initTitleButtonBar();
		initWindow();
	}

	private void initTitleButtonBar() {
		final TextView titleTv = (TextView) findViewById(R.id.tv_title);
		titleTv.setText(getString(R.string.news_top_title));

		final ImageButton backBtn = (ImageButton) findViewById(R.id.btn_back);
		backBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	private void initWindow() {
		View convertView = findViewById(R.id.lyt_parent);
		PullToRefreshListView listView = (PullToRefreshListView) convertView
				.findViewById(R.id.lst_default_list);
		NewsListHandler handler = new NewsListHandler(this, convertView);
		new NewsListAdapter(listView, this, convertView,
				R.layout.layout_loading, R.layout.layout_reloading, handler);

	}
}
